package iscript.coreFramework.util 
{
	 import flash.utils.ByteArray;
	 public class StringEncode
	 {
	  
	  static public function encodeGB2312(str:String):String{
		   var result:String ="";
		   var byte:ByteArray =new ByteArray();
		   byte.writeMultiByte(str,"gb2312");
		   for(var i:int;i<byte.length;i++){
			result += escape(String.fromCharCode(byte[i]));
		   }
		   return result;
	  }

	  static public function encodeBIG5(str:String):String{
		   var result:String ="";
		   var byte:ByteArray =new ByteArray();
		   byte.writeMultiByte(str,"big5");
		   for(var i:int;i<byte.length;i++){
			result += escape(String.fromCharCode(byte[i]));
		   }
		   return result;
	  }

	  static public function encodeGBK(str:String):String{
		   var result:String ="";
		   var byte:ByteArray =new ByteArray();
		   byte.writeMultiByte(str,"gbk");
		   for(var i:int;i<byte.length;i++){
			result += escape(String.fromCharCode(byte[i]));
		   }
		   return result;
	  }
      
	  static public function encode(str:String,code:String):String
		{
			var stringresult:String = "";
			var byte:ByteArray =new ByteArray();
			byte.writeMultiByte(str,code);
			for (var i:int; i<byte.length; i++)
			{
				stringresult +=  escape(String.fromCharCode(byte[i]));
			}
			return stringresult;
		}
	  
	 }
}